package io.renren.modules.equipinfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.orginfo.entity.OrginfoEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.equipinfo.entity.EquipinfotableEntity;
import io.renren.modules.equipinfo.service.EquipinfotableService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

@RestController
@RequestMapping("equipinfo/equipinfotable")
public class EquipinfotableController {
    @Autowired
    private EquipinfotableService equipinfotableService;

    @GetMapping("getEquip")
    public List<EquipinfotableEntity> getEquip(@RequestParam(value = "equipName",required = false) String equipName){
        return equipinfotableService.getEquip(equipName);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
   // @RequiresPermissions("equipinfo:equipinfotable:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = equipinfotableService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 查询人数接口
     */
    @GetMapping(value = "/num",produces = {"application/json;charset=UTF-8"})
    public List listNum(){
        return equipinfotableService.listNum();
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{no}")
   // @RequiresPermissions("equipinfo:equipinfotable:info")
    public R info(@PathVariable("no") Integer no){
		EquipinfotableEntity equipinfotable = equipinfotableService.getById(no);

        return R.ok().put("equipinfotable", equipinfotable);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
   // @RequiresPermissions("equipinfo:equipinfotable:save")
    public R save(@RequestBody EquipinfotableEntity equipinfotable){
		equipinfotableService.save(equipinfotable);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
   // @RequiresPermissions("equipinfo:equipinfotable:update")
    public R update(@RequestBody EquipinfotableEntity equipinfotable){
		equipinfotableService.updateById(equipinfotable);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
   // @RequiresPermissions("equipinfo:equipinfotable:delete")
    public R delete(@RequestBody Integer[] nos){
		equipinfotableService.removeByIds(Arrays.asList(nos));

        return R.ok();
    }

}
